<script src="jquery-3.2.1.min.js"></script>
<h1>触达云屏-大屏客户端-内容推送</h1>
<div class="table_box">
	触达云屏，让人人都能实现数据可视化，使用文档地址：<a href="http://yunping.doc.chudayun.com" target="_blank">http://yunping.doc.chudayun.com</a>
</div>
<div class="table_box">
	<p>1,先选择设备
		<br>
		2,填写数据
		<br>
		3,点击推送
	</p>
	<select id="deviceList" name="deviceid" style="width: 80%"></select>
	<br><br>
	<textarea name="contentData" id="contentData" style="width: 80%" rows="10">[{
	"url": "http://datavisual.hezyun.cn:18088/chudy_visual/view/1514804998528040960",
	"duration": 5,
	"id": "1001"
}]</textarea>
	<table style="width: 80%;border-color: #0aafe6;border-spacing: 0px" cellpadding="0" border="1">
		<tr><td style="width: 100px">url</td><td>看板url地址</td></tr>
		<tr><td>duration</td><td>播放时长（单位：秒）</td></tr>
		<tr><td>id</td><td>看板id，唯一标识</td></tr>
	</table>
	<br/><br/>
	<input type="button" onclick="submitData()" value="推送">
	<br/><br/>

</div>
<script>
	$.ajax({
		type: 'POST',
		url: "/client/devicelist",
		data: {},
		success: function(res){

			$.each(res.data,function(index,item){
				console.log(item);
				var label = "设备ID：" + item.deviceid + ",设备IP："  + item.deviceip;
				$("<option value="+item.deviceid+">"+ label +"</option>").appendTo("#deviceList");
			});
		},
		dataType: "json"
	});
	function submitData(){
		console.log($("#contentData").val());
		$.ajax({
			type: 'POST',
			contentType: "application/json; charset=utf-8",
			url: "/push?deviceid=" + $("#deviceList").val(),
			data: $("#contentData").val(),
			success: function(res){
				alert("推送完成");
			},
			dataType: "json",
			error:function(error){
				alert("推送异常");
			}
		});
	}
</script>
